/*
 * Copyright 2008-2023 dexian.vip. All rights reserved.
 * Support: http://www.dexian.vip
 * License: http://www.dexian.vip/license
 */

package vip.dexian.admin.controller;

import vip.dexian.admin.base.BaseController;
import vip.dexian.admin.dto.AdminPrincipal;
import vip.dexian.admin.service.AdminService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 首页controller
 */
@Controller ("adminIndexController")
@RequestMapping ("/admin/index")
public class IndexController extends BaseController {

    /**
     * 管理员
     */
    @Resource (name = "adminServiceImpl")
    private AdminService adminService;

    /**
     * 进入首页
     *
     * @param model
     *         模型
     * @param request
     *         {@link HttpServletRequest}
     * @param response
     *         {@link HttpServletResponse}
     *
     * @return 首页
     */
    @GetMapping
    public String index (ModelMap model, HttpServletRequest request, HttpServletResponse response) {

        AdminPrincipal admin = this.adminService.getCurrent();

        model.addAttribute("admin", admin);

        return "/admin/main/index";
    }
}
